﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Lilium.UI.Forms
{
    public sealed class ButtonAdapter : ControlAdapter<Button>, IPushButton
    {
        public ButtonAdapter(Button control)
            : base(control)
        {
            if (control == null) throw new ArgumentNullException("control");
            control.Click += (object sender, EventArgs e) => OnClick();
        }

        #region ISource<Nothing> Members

        public event Action<Nothing> Pushed;

        #endregion

        private void OnClick()
        {
            var pushed = Pushed;
            if (pushed != null)
                pushed(Nothing.Value);
        }
    }
}